package com.jeady.timetodo.base

import android.content.Context
import android.widget.Toast
import androidx.compose.ui.graphics.Color


fun showToast(context: Context, title: String){
    Toast.makeText(context, title, Toast.LENGTH_SHORT).show()
}

fun setClipboard(context: Context, title: String){
    val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
    val clipData = android.content.ClipData.newPlainText("text", title)
    clipboardManager.setPrimaryClip(clipData)
    showToast(context, "已复制")
}

fun Color.subtract(color: Color): Color {
    return Color(
        red = red - color.red,
        green = green - color.green,
        blue = blue - color.blue,
        alpha = alpha - color.alpha
    )
}

fun Map<String, Any>.getKeyByValue(value: Any): String? {
    return this.entries.firstOrNull { it.value == value }?.key
}